local qizheng = fk.CreateSkill{
  name = "lingling__qizheng",
}

Fk:loadTranslationTable{
  ["lingling__qizheng"] = "奇正",
  [":lingling__qizheng"] = "出牌阶段限一次，你可以弃置一张锦囊牌并指定一名其他角色，你暗中选择：若其未打出【杀】，你获得其一张牌；"..
  "若其未打出【闪】，你对其造成1点伤害。然后其打出一张牌，若为【杀】或【闪】则重置此技能。",

  ["#lingling__qizheng"] = "奇正：秘密选择一项，令一名角色执行效果<br>正兵：未出杀，获得其一张牌；奇兵：未出闪，对其造成伤害",
  ["#lingling__qizheng-ask"] = "奇正：请打出一张牌<br>正兵：未出杀，%src 获得你牌；奇兵：未出闪，你受到伤害",
  ["lingling__qizheng_raid"] = "奇兵",
  ["lingling__qizheng_frontal"] = "正兵",
}

qizheng:addEffect("active", {
  anim_type = "offensive",
  prompt = "#lingling__qizheng",
  interaction = UI.ComboBox { choices = { "lingling__qizheng_frontal", "lingling__qizheng_raid" }},
  card_num = 1,
  target_num = 1,
  can_use = function(self, player)
    return player:usedSkillTimes(qizheng.name, Player.HistoryPhase) == 0
  end,
  card_filter = function(self, player, to_select, selected)
    return #selected == 0 and Fk:getCardById(to_select).type == Card.TypeTrick and not player:prohibitDiscard(to_select)
  end,
  target_filter = function (self, player, to_select, selected, selected_cards)
    return #selected == 0 and to_select ~= player
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    room:throwCard(effect.cards, qizheng.name, player, player)
    if player.dead or target.dead then return end
    local respond = room:askToResponse(target, {
      skill_name = qizheng.name,
      pattern = ".",
      prompt = "#lingling__qizheng-ask:"..player.id,
      cancelable = target:isNude(),
    })
    if respond then
      room:responseCard(respond)
      if respond.card.trueName == "slash" or respond.card.trueName == "jink" then
        player:setSkillUseHistory(qizheng.name, 0, Player.HistoryPhase)
      end
      if target.dead then return end
    end
    if self.interaction.data == "lingling__qizheng_frontal" and not (respond and respond.card.trueName == "slash") then
      if not player.dead and not target:isNude() then
        local card = room:askToChooseCard(player, {
          target = target,
          flag = "he",
          skill_name = qizheng.name,
        })
        room:moveCardTo(card, Card.PlayerHand, player, fk.ReasonPrey, qizheng.name, nil, false, player)
      end
    elseif self.interaction.data == "lingling__qizheng_raid" and not (respond and respond.card.trueName == "jink") then
      if not target.dead then
        room:damage{
          from = player,
          to = target,
          damage = 1,
          skillName = qizheng.name,
        }
      end
    end
  end,
})

return qizheng

